package com.pm25.request;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.pm25.exception.ValidateException;
import com.pm25.response.AqiDetailsResponse;

public class AqiDetailsRequest implements Request<AqiDetailsResponse> {

	private String city;
	private Boolean avg;
	private String stations;

	public String getCity() {
		return city;
	}

	/**
	 * 
	 * @Title setCity
	 * @param city
	 *            城市名称，必选参数
	 */
	public void setCity(String city) {
		this.city = city;
	}

	public Boolean getAvg() {
		return avg;
	}

	/**
	 * 
	 * @Title setAvg
	 * @param avg
	 *            是否返回一个城市所有监测点数据均值的标识，可选参数，默认是true，不需要均值时传这个参数并设置为false
	 */
	public void setAvg(Boolean avg) {
		this.avg = avg;
	}

	public String getStations() {
		return stations;
	}

	/**
	 * 
	 * @Title setStations
	 * @param stations
	 *            是否只返回一个城市均值的标识，可选参数，默认是yes，不需要监测点信息时传这个参数并设置为no
	 */
	public void setStations(String stations) {
		this.stations = stations;
	}

	public void valid() throws ValidateException {
		if (StringUtils.isBlank(city)) {
			throw new ValidateException("城市名称不能为空");
		}
	}

	public Map<String, String> getParamterMaps() {
		Map<String, String> param = new HashMap<>();
		param.put("city", city);
		param.put("avg", String.valueOf(avg));
		param.put("stations", stations);
		return param;
	}

	public String getUri() {
		return "/api/querys/aqi_details.json";
	}

	public Class<AqiDetailsResponse> getResponseClass() {
		return AqiDetailsResponse.class;
	}

}
